package com.wit.witmg.api;


import com.wit.witmg.service.ITStockService;
import com.wit.witmg.service.ITToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author bob
 * @since 2024-12-12
 */
@RestController
@RequestMapping("tool")
@Api(tags = "工装模具API")
public class ToolController {
    @Resource
    private ITToolService service;

    @ApiOperation("添加")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

    @ApiOperation("获取")
    @PostMapping("get")//oid部门编号，返回oid以参数开头并包含参数的数据；bn模糊搜索返回数组（前端支持二维码识别），id返回单条数据，常用于连表查询，类型标签模糊查询（参数为多个关键字用“，”隔开，返回同时包含这些关键字的数据）
    public Object get(HttpServletRequest request,
                      @RequestParam(value = "oid",required = false) String oid,
                      @RequestParam(value = "bn",required = false) String bn,
                      @RequestParam(value = "id",required = false) Integer id,
                      @RequestParam(value = "tp",required = false) String tp)
    {
        return service.get(request,oid,bn,id,tp);
    }

    @ApiOperation("删除")
    @PostMapping("del")
    public Object del(HttpServletRequest request,
                      @RequestParam("id") Integer id) {
        return service.del(request,id);
    }
}
